/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sistema_comercial.util.dominio;

import java.util.UUID;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

/**
 *
 * @author Fabio
 */
@MappedSuperclass
public abstract class ObjetoDominioImpl implements ObjetoDominio {
    
    private static final long serialVersionUID = 1;
    
    @Basic
    @Column(nullable=false, length=40)
    protected String uuid;
    
    public ObjetoDominioImpl(){
        uuid = UUID.randomUUID().toString();
    }
    
    @Override
    public String getUuid() {
        return this.uuid;
    }
    
    public void setUuid(String uuid){
        this.uuid = uuid;
    }
    
    	@Override
	public boolean equals(Object obj) {
		if ((obj == null) || (!getClass().equals(obj.getClass())))
			return false;
		ObjetoDominioImpl o = (ObjetoDominioImpl) obj;

		return uuid.equals(o.uuid);
	}

	@Override
	public int hashCode() {
		return uuid.hashCode();
	}

	public int compareTo(ObjetoDominioImpl o) {
		return uuid.compareTo(o.uuid);
	}
}
